

function inspectMaterialToPrintCtrl($rootScope, $scope, $http, ngDialog, paFetchService, ngDialogProblem) {
  'ngInject';

  // 查询条件的对象,筛选出problemStatus为2的状态的数据
  this.queryData = {
    queryType: 0, //pc:0,app:1
    problemStatus: 2, // 已完成
    checkResult: 0, // 不符合要求
    role: 1,// 总监办
  };

  // 分页
  this.paginationData = {
    pageNum: 0,
    pageSize: 10,
    total: '',
  }

  // 页码变化时调用方法
  $scope.pageChange = () => {
  	this.paginationData1 = {
  	  pageNum: this.paginationData.pageNum-1,
  	  pageSize: 10,
  	  total: '',
  	}

    $http.post(`${SERVER_CONTEXT}/api/checkRecord/app/queryCheckProblemListByCondition`,
      angular.extend(this.queryData, this.paginationData1)
        )
      .then((resp) => {
        this.inspectMaterialToPrintList = resp.data.data;
        this.paginationData.total = resp.data.total;
    });
  };

  // 分页查询方法
  this.paginationQuery = () => {
    if (this.paginationData.pageNum) {
      this.paginationData2 = {
        pageNum: this.paginationData.pageNum-1,
        pageSize: 10,
        total: '',
      }
    } else {
      this.paginationData2 = {
        pageNum: 0,
        pageSize: 10,
        total: '',
      }
    }
    $http.post(`${SERVER_CONTEXT}/api/checkRecord/app/queryCheckProblemListByCondition`,
      angular.extend(this.queryData, this.paginationData2)
        )
      .then((resp) => {
        this.inspectMaterialToPrintList = resp.data.data;
        this.paginationData.total = resp.data.total;
    });
  };

  // 重置
  this.reset = () => {
    this.queryData = {
    	queryType: 0,
      problemStatus: 2, // 已完成
      checkResult: 0, // 不符合要求
      role: 1, // 总监办
      bidId: $rootScope.activeBid.tenderId,
    };
  }

  // 查询
  this.query = (param) => {
  	if(param.endTime.$viewValue && param.startTime.$viewValue){
  	  if (param.startTime.$viewValue < param.endTime.$viewValue) {
  	    this.paginationQuery();
  	} else {
  	    layer.alert('巡查提交开始时间应小于结束时间');
  	  }
  	} else {
  	  this.paginationQuery();
  	}
  }

}

export default inspectMaterialToPrintCtrl;